package com.config;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitmqFanoutConfig {


    /**
     * 创建扇形交换机
     * @return
     */
    @Bean
    public FanoutExchange fanoutExchange()
    {
        System.out.println("FanoutExchange交换机创建了");
        return new FanoutExchange("fanoutExchange");
    }

    /**
     * 创建队列1
     * @return
     */
    @Bean
    public Queue createQueue1()
    {
        return new Queue("fanoutQueue1");
    }

    /**
     * 创建队列1
     * @return
     */
    @Bean
    public Queue createQueue2()
    {
        return new Queue("fanoutQueue2");
    }

    @Bean
    public Binding  bind3()
    {
        return BindingBuilder.bind(createQueue1()).to(fanoutExchange());
    }

    @Bean
    public Binding  bind4()
    {
        return BindingBuilder.bind(createQueue2()).to(fanoutExchange());
    }


}
